import 'package:get/get.dart';
import 'package:tiktokadult/hj_model/mine/OfficialListItemModel.dart';
import 'package:tiktokadult/hj_utils/api_service/mine_service.dart';

class MineDriveLogic extends GetxController with GetTickerProviderStateMixin {
  List<OfficialListItemModel>? allList;
  List<OfficialListItemModel> groupList = [];
  List<OfficialListItemModel> officialList = [];

  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
    loadData();
  }

  Future<void> loadData() async {
    allList ??= [];
    allList = await MineService.getOfficialLists();

    if ((allList?.length ?? 0) > 0) {
      var item = allList?.where((element) => element.officialName?.contains('商务') ?? false);
      var group = allList?.where((element) => !(element.officialName?.contains('商务') ?? false));
      if (item != null) {
        officialList.addAll(item);
      }
      if (group != null) {
        groupList.addAll(group);
      }
    }
    update();
  }
}
